-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[Python] Fix AttributeError in ExternalTransform.expand by using get_type_hints() #37299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Python] Fix AttributeError in ExternalTransform.expand by using get_type_hints() #37299
Conversation
Summary of ChangesHello @Eliaaazzz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #37299 +/- ##
============================================
+ Coverage 55.16% 55.17% +0.01%
Complexity 1676 1676
============================================
Files 1068 1068
Lines 167257 167342 +85
Branches 1208 1208
============================================
+ Hits 92261 92338 +77
- Misses 72816 72824 +8
Partials 2180 2180
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Assigning reviewers: R: @jrmccluskey for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
8fe6cc6 to
69f022f
Compare
…type_hints() (Fixes apache#37289)
69f022f to
e74143d
Compare
|
I have pushed the fix for the linting issue. Regarding the Python 3.13 failure, it seems unrelated to my changes since the tests for Python 3.10, 3.11, and 3.12 all passed. I also noticed the logs indicate '272 similar failures in the previous 7 days', suggesting this might be a known flaky test in the CI environment. Could you please take a look? |
|
Thanks @derrickaw! I've fixed the line length issue in the latest commit. Standing by for the next steps. |
|
Looks like a few more lint issues that need resolving. Make sure to have gone through this to assist - https://github.com/apache/beam/blob/master/contributor-docs/python-tips.md#lint-and-formatting-checks |
33e8676 to
7510d50
Compare
Hi Derrick, the CI checks are all green now. The previous failure appeared to be a flaky test (infrastructure issue with Socket closed), and it passed successfully after a retry. Please let me know if there is anything else needed. Thanks! |
|
LGTM - will let @jrmccluskey do final review. Thanks. |
Thanks for your patience and guidance, appreciate it! |
jrmccluskey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Good catch, thanks!
|
Description
Fixes #37289: Replaces direct access to the internal_type_hintsattribute with the publicget_type_hints()accessor inExternalTransform.expand().Why this is needed
Directly accessing
self._type_hintscauses anAttributeErrorif the type hints have not been explicitly initialized before the expansion phase. This issue was observed specifically when usingStorageWriteToBigQuerywithwith_auto_sharding=True, which triggers anExternalTransformexpansion where_type_hintsis missing.Using
get_type_hints()is the correct, defensive approach as it ensures valid type hints (or an empty instance) are returned, preventing the crash.Testing
StorageWriteToBigQuerywith auto-sharding enabled.AttributeErrorand allows the pipeline to proceed past the expansion phase.Checklist
addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.